import shelve
import pdb


fieldnames = ('name', 'age', 'job', 'pay')
maxfield = max(len(f) for f in fieldnames)
db = shelve.open('class-shelve')

while True:
	k = raw_input('\nkey?=> ')
	if not k: break
	else:
		try:
			record = db[k]
			for field in fieldnames:
				print(field.ljust(maxfield), '=>', getattr(record, field))
		except:
			print('No such key %s!' % k)
	
